<!DOCTYPE html>
<html xmlns:th="http://www.w3.org/1999/xhtml" xmlns:text-align="http://www.w3.org/1999/xhtml">
<head lang="en">
    <meta charset="UTF-8" />
    <title></title>
    <script th:src="@{js/jquery.min.js}" type="text/javascript" ></script>
    <script>
        function checkout(obj) {
            var reg = /^(?!update|delete).*/;
            var sql = $("#inputsql").val();
            if (!reg.test(sql)) {
                alert('请输入符合格式的sql语句');
                obj.value = "";
                obj.focus();
                return false;
            }
        }

        function save(){
            var sql = $("#inputsql").val();  //通过表单元素id取值。
            $.ajax({
                    async: false
                    , cache: false
                    , dataType: "json"
                    , data: {
                        "sql": sql
                    }
                    , type: "POST"
                    , url: "/get/sql"
                    , processData: true
                    , success: function (data, textStatus) {
                        if (textStatus == "success") {
                            alert(data.message)
                        }
                    }
                }
            );
        }
    </script>
</head>
<body>
<form method="POST">
    <div>
<textarea id="inputsql" cols="250" rows="40" onblur="checkout(this)">
</textarea>
    </div>
    <div>
        <button onclick="save()" type="submit" >Click Me!</button>
    </div>
</form>
</body>
</html>